package sheduler;

import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.TimeUnit;

/**
 * @Date 2021/11/12
 * @Created by Jonathan
 */
public class TimerDemo {
    public static void main(String[] args) throws InterruptedException {
        Timer timer = new Timer("time-1");
        timer.scheduleAtFixedRate(new TimerTask() {
            @Override
            public void run() {
                System.out.println("hello world");
            }
        }, 0, 1000);
        //timer.cancel();

        TimeUnit.SECONDS.sleep(1);
    }
}
